package homework.exp06;


import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class G {
    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileInputStream(new File("src/homework/exp06/G.in")));
        } catch (IOException e) {
            cin = new Scanner(System.in);
        }
    }
    static int n, h, t, cur;
    static int[][] a = new int[101][101];
    static int[] book = new int[101];

    public static void main(String[] args) {

        int[] q = new int[2501];
        n = cin.nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = cin.nextInt();
            }
        }
        h = 0;t = 0;
        q[t] = 0;t++;book[0] = 1;
        while (h < t && t <= n - 1) {
            cur = q[h];
            for (int i = 0; i < n; i++) {
                if (a[cur][i] == 1 && book[i] == 0) {
                    q[t] = i;
                    t++;
                    book[i] = 1;
                }
            }
            h++;
        }
        for (int i = 0; i < t; i++) {
            System.out.print(q[i] + " ");
        }
    }
}